cc.Class({

    extends: cc.Component,

    properties: {

        autoPlay : false,

        interval: 5,        // 以秒为单位的时间间隔

        repeat: -1,        // 重复次数

        delay: 0,        // 开始延时

        audio: {
            default: null,
            type: cc.AudioSource,
            visible: false,
            serializable: false,
        },
    },

    onLoad() {

        this.audio = this.node.getComponent(cc.AudioSource);

        if (this.autoPlay) {

            if (this.audio != null) {

                this.schedule(function () {

                    this.audio.play();

                }, this.interval, this.repeat, this.delay);
            }
        }
    },

    playAudio() {

        this.audio.play();
    },
});
